package com.yq.leetcodeOld.tree;

import java.util.ArrayList;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;

/**
 * @ClassName Solution94
 * @Description TODO
 * @Author yaoqiang
 * @Date 2022/3/22 13:42
 * @Version 1.0
 */
public class Solution94 {
    public static void main(String[] args) {

    }

    public List<Integer> inorderTraversal(TreeNode root) {
        List<Integer> res =new ArrayList<>();
        Deque<TreeNode> stk=new LinkedList<>();
        while (root!=null||!stk.isEmpty()){
            while (root!=null){
                stk.push(root);
                root=root.left;
            }
             root = stk.pop();
            res.add(root.val);
            root= root.left;
        }
        return res;
    }
}

